package core;
import java.util.HashMap;
import java.util.LinkedList;

import org.newdawn.slick.geom.Point;

import org.newdawn.slick.*;


public class Gayme extends BasicGame{
	
	float scale;
	long lastScale = 1000;
	long lastMove = 1000;
	int height = 500;
	int width = 800;
	float acc = .00000000000001f;
	long falltime = 0;
	boolean falling = false;
	float fallspeed = 0;
	long inputCheck = 1;
	public Player p;
	public Input in;
	public HashMap<Unit, Unit> units;
	public LinkedList<Block> blocks;
	public int camX;
	public float camY;
	

	public Gayme(String title) throws SlickException{
		super(title);
	}

	@Override
	public void render(GameContainer gc, Graphics arg1) throws SlickException {
		p.draw(p.tex,p.x,p.y);
		for(Block b:blocks)
			b.draw();
		
	}

	@Override
	public void init(GameContainer gc) throws SlickException {
		
		this.p = new Player(100,400,"core/bro.png",this);
	
		scale = 1f;
		
		units = new HashMap<Unit, Unit>();
		blocks = new LinkedList<Block>();
		blocks.addFirst(new Block("core/woodblock.png",false,300f,300f));
		blocks.addFirst(new Block("core/woodblock.png",false,100f,400f));
		blocks.addFirst(new Block("core/woodblock.png",false,100f,490f));
		blocks.addFirst(new Block("core/woodblock.png",false,100f,480f));
		blocks.addFirst(new Block("core/woodblock.png",false,100f,470f));
	}

	public boolean canMove(Unit u, String dir){
		if(dir == "w")
			if(u.position.y<=1)
				return false;
		if(dir =="a")
			if(u.position.x<=1)
				return false;
		if(dir == "s")
			if(u.position.y>= (height-1))
				return false;
		if(dir == "d")
			if(u.position.x>=width-1)
				return false;
		return true;
	}

	@Override
	public void update(GameContainer gc, int arg1) throws SlickException {

		if(System.nanoTime()-inputCheck>13333337){
			inputCheck = System.nanoTime();
			in = gc.getInput();
			p.move(in);
		}
	}
	public static void main(String args[]) throws SlickException{
		AppGameContainer app = new AppGameContainer(new Gayme("onby"));
		app.setDisplayMode(800, 500, false);
		app.start();
		
		app.setTargetFrameRate(60);


	}

	public int getHeight() {
		return height;
	}

	public int getWidth() {
		return width;
	}

}
